package sudroid.json;

public class Cookie
{
  public static String escape(String paramString)
  {
    String str = paramString.trim();
    StringBuffer localStringBuffer1 = new StringBuffer();
    int i = str.length();
    int j = 0;
    if (j >= i)
      return localStringBuffer1.toString();
    int k = str.charAt(j);
    if ((k < 32) || (k == 43) || (k == 37) || (k == 61) || (k == 59))
    {
      StringBuffer localStringBuffer2 = localStringBuffer1.append(37);
      char c1 = Character.forDigit((char)(k >>> 4 & 0xF), 16);
      StringBuffer localStringBuffer3 = localStringBuffer1.append(c1);
      char c2 = Character.forDigit((char)(k & 0xF), 16);
      StringBuffer localStringBuffer4 = localStringBuffer1.append(c2);
    }
    while (true)
    {
      j += 1;
      break;
      StringBuffer localStringBuffer5 = localStringBuffer1.append(k);
    }
  }

  public static JSONObject toJSONObject(String paramString)
    throws JSONException
  {
    JSONObject localJSONObject1 = new JSONObject();
    JSONTokener localJSONTokener = new JSONTokener(paramString);
    String str1 = localJSONTokener.nextTo(61);
    JSONObject localJSONObject2 = localJSONObject1.put("name", str1);
    int i = localJSONTokener.next(61);
    String str2 = localJSONTokener.nextTo(59);
    JSONObject localJSONObject3 = localJSONObject1.put("value", str2);
    int j = localJSONTokener.next();
    if (!localJSONTokener.more())
      return localJSONObject1;
    String str3 = unescape(localJSONTokener.nextTo("=;"));
    Object localObject;
    if (localJSONTokener.next() != 61)
      if (str3.equals("secure"))
        localObject = Boolean.TRUE;
    while (true)
    {
      JSONObject localJSONObject4 = localJSONObject1.put(str3, localObject);
      break;
      throw localJSONTokener.syntaxError("Missing '=' in cookie parameter.");
      localObject = unescape(localJSONTokener.nextTo(59));
      int k = localJSONTokener.next();
    }
  }

  public static String toString(JSONObject paramJSONObject)
    throws JSONException
  {
    StringBuffer localStringBuffer1 = new StringBuffer();
    String str1 = escape(paramJSONObject.getString("name"));
    StringBuffer localStringBuffer2 = localStringBuffer1.append(str1);
    StringBuffer localStringBuffer3 = localStringBuffer1.append("=");
    String str2 = escape(paramJSONObject.getString("value"));
    StringBuffer localStringBuffer4 = localStringBuffer1.append(str2);
    if (paramJSONObject.has("expires"))
    {
      StringBuffer localStringBuffer5 = localStringBuffer1.append(";expires=");
      String str3 = paramJSONObject.getString("expires");
      StringBuffer localStringBuffer6 = localStringBuffer1.append(str3);
    }
    if (paramJSONObject.has("domain"))
    {
      StringBuffer localStringBuffer7 = localStringBuffer1.append(";domain=");
      String str4 = escape(paramJSONObject.getString("domain"));
      StringBuffer localStringBuffer8 = localStringBuffer1.append(str4);
    }
    if (paramJSONObject.has("path"))
    {
      StringBuffer localStringBuffer9 = localStringBuffer1.append(";path=");
      String str5 = escape(paramJSONObject.getString("path"));
      StringBuffer localStringBuffer10 = localStringBuffer1.append(str5);
    }
    if (paramJSONObject.optBoolean("secure"))
      StringBuffer localStringBuffer11 = localStringBuffer1.append(";secure");
    return localStringBuffer1.toString();
  }

  public static String unescape(String paramString)
  {
    int i = paramString.length();
    StringBuffer localStringBuffer1 = new StringBuffer();
    int j = 0;
    if (j >= i)
      return localStringBuffer1.toString();
    int k = paramString.charAt(j);
    if (k == 43)
      k = 32;
    while (true)
    {
      StringBuffer localStringBuffer2 = localStringBuffer1.append(k);
      j += 1;
      break;
      if ((k != 37) || (j + 2 >= i))
        continue;
      int n = j + 1;
      int i1 = JSONTokener.dehexchar(paramString.charAt(n));
      int i2 = j + 2;
      int i3 = JSONTokener.dehexchar(paramString.charAt(i2));
      if ((i1 < 0) || (i3 < 0))
        continue;
      int m = (char)(i1 * 16 + i3);
      j += 2;
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     sudroid.json.Cookie
 * JD-Core Version:    0.6.0
 */